import time
import unittest
from selenium import webdriver

from POM.pageObjext.collectObject import CollectObject
from POM.pageObjext.loginObject import LoginObject
from POM.pageObjext.gImageObject import GImageObject
from ddt import ddt, file_data, data


@ddt
class TestCase(unittest.TestCase):

    @classmethod
    def setUpClass(cls) -> None:
        cls.driver = webdriver.Chrome("C:\Program Files\chromedriver.exe")

        cls.lg = LoginObject(cls.driver)
        cls.gImage = GImageObject(cls.driver)
        cls.collect = CollectObject(cls.driver)

    @classmethod
    def tearDownClass(cls) -> None:
        cls.driver.quit()

    @file_data('../data/user_test.yaml')
    def test_1_login(self, mobile, password):

        self.lg.login(mobile, password)

        time.sleep(2)

    @data('病毒', '癌症')
    def test_2_search(self, s):
        # search = '病毒'
        self.gImage.operation(s)
        time.sleep(2)

    # def test_3_collect(self):
    #     self.collect.collect()
    #     time.sleep(2)


if __name__ == '__main__':
    unittest.main()
